package br.com.projeto.persistence;

import br.com.projeto.entity.EnderecoVO;

public class EnderecoDAO extends BaseDAO{
	
	public void inserirEndereco(EnderecoVO enderecoVO) throws Exception{
		open();
		stmt = con.prepareStatement("INSERT INTO endereco (" +
												"	seq_usuario, " +
												"	logradouro, " +
												"	numero, " +
												"	complemento, " +
												"	bairro, " +
												"	cidade, " +
												"	estado, " +
												"	cep, " +
												"	tel_comercial, " +
												"	tel_residencial, " +
												"	tel_celular) " +
												" VALUES(upper(?),upper(?),upper(?),upper(?),upper(?),upper(?),upper(?),upper(?),upper(?),upper(?),upper(?))");
        stmt.setInt(1, enderecoVO.getSeqEndereco());
        stmt.setString(2, enderecoVO.getLogradouro());
        stmt.setString(3, enderecoVO.getNumero());
        stmt.setString(4, enderecoVO.getComplemento());
        stmt.setString(5, enderecoVO.getBairro());
        stmt.setString(6, enderecoVO.getCidade());
        stmt.setString(7, enderecoVO.getEstado());
        stmt.setString(8, enderecoVO.getCep());
        stmt.setString(9, enderecoVO.getTelComercial());
        stmt.setString(10, enderecoVO.getTelResidencial());
        stmt.setString(11, enderecoVO.getTelCelular());
        stmt.executeUpdate();
        stmt.close();
        close();
	}
	
	public void alterarEndereco(EnderecoVO enderecoVO) throws Exception{
		open();
		stmt = con.prepareStatement("UPDATE endereco " +
									"SET 	logradouro = upper(?), " +
									"		numero = upper(?), " +
									"		complemento = upper(?), " +
									"		bairro = upper(?), " +
									"		cidade = upper(?), " +
									"		estado = upper(?), " +
									"		cep = upper(?), " +
									"		tel_comercial = upper(?), " +
									"		tel_residencial = upper(?), " +
									"		tel_celular = upper(?) " +
									"WHERE 	seq_usuario = ?");
	        stmt.setString(1, enderecoVO.getLogradouro());
	        stmt.setString(2, enderecoVO.getNumero());
	        stmt.setString(3, enderecoVO.getComplemento());
	        stmt.setString(4, enderecoVO.getBairro());
	        stmt.setString(5, enderecoVO.getCidade());
	        stmt.setString(6, enderecoVO.getEstado());
	        stmt.setString(7, enderecoVO.getCep());
	        stmt.setString(8, enderecoVO.getTelComercial());
	        stmt.setString(9, enderecoVO.getTelResidencial());
	        stmt.setString(10, enderecoVO.getTelCelular());
	        stmt.setInt(11, enderecoVO.getSeqEndereco());
        stmt.execute();
        stmt.close();
        close();
	}
	
}
